require('es6-promise').polyfill();

import axios from 'axios'

export function createDemoData(data) {
  return {
    type: 'CREATE_DEMO_DATA',
    data,
    date: Date.now()
  }
}
export function editDemoData(id, data) {
  return {
    type: 'EDIT_DEMO_DATA',
    id,
    data,
    date: Date.now()
  };
}
export function deleteDemoData(id) {
  return {
    type: 'DELETE_DEMO_DATA',
    id
  };
}

function loadDemoData(data) {
  return {
    type: 'LOAD_DEMO_DATA',
    data
  }
}


export function loadDemoDataAsync(filter) {
  return function(dispatch) {
    dispatch(loadDemoData({
      data: [
        {
          id: '1',
          name: 'test1',
          phone: '13111111111'
        },
        {
          id: '2',
          name: 'test2',
          phone: '15212345678'
        }
      ]
    }))
  };
}
